package it.pir.es05ChatTCP_TLS;

import java.io.*;
import java.net.UnknownHostException;

public class ClientTest {
	
	private static final int PORT = 7777;

	public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException {
		String nickname = args[0];
		String host = args[1];
		
		BufferedReader tastiera = new BufferedReader(new InputStreamReader(System.in));

		// TODO: qui si cambiano le implementazioni
		Client client = new ClientObj(nickname, host, PORT);
		//Client client = new ClientBin(nickname, host, PORT);
		//Client client = new ClientTxt(nickname, host, PORT);
		
		/* Eseguimao il thread che legge in continuazione se arrivano messaggi*/
		Thread t = new Thread(client);
		t.start();
		
		/* Contemporaneamente nel thread principale (il main) inviamo messaggi*/
		while(true) {
			String s = tastiera.readLine();
			client.sendMessage(new Message(nickname, s, Message.MESSAGE));
		}
	}

}
